{extends file="base.html"}

{block name=base}
<div class="box_sort">
    <div class="box_content">
        <ul id="sortable" class="list">
            {foreach $list as $item}
            <li class="ui-state-default clearfix">
                <table width="100%" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                        <td class="sort_left"><a rel="{$item.id}">{$item.id}<span class="em">:)</span>{$item.title}</a></td>
                        <td class="sort_rght">
                        {if $item.image}
                        <img  src="{$root}{$item.thumb|default:$item.image}" alt="" />
                        {/if}
                        </td>
                    </tr>
                </table>
            </li>
            {/foreach}
        </ul>
        <form method="post" onsubmit="return order_submit()">
            <input name="data[order]" type="hidden" />
            <div style="text-align: center;padding-top: 15px;">
                <input  type="submit" class="layui-btn" value="提交"/>
            </div>
        </form>
    </div>
</div>
{$smarty.block.child}
{/block}

{block name=script}
<script type="text/javascript">
$( "#sortable" ).sortable({
	placeholder: "ui-state-highlight"
});
$( "#sortable" ).disableSelection();

function order_submit(){
    
    var order_arr=[];
	$('li.ui-state-default').each(function(){
		order_arr.push($(this).find('a').attr('rel'));
	})
	$('input[name="data[order]"]').val(order_arr.join(','));
	return true;
}

</script>
{/block}